home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Communications Toolbox / CTB Development Resources / Simple FT Tool / Simon Tool / Validation.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-12  |  18.6 KB  |  748 lines  |  [TEXT/MPS ]

  1. /************************************************************************************
  2.                                   P R O J E C T   I N F O
  3. *************************************************************************************
  4.   
  5.     Project Name:    Simon
  6.        File Name:    Validation.c
  7.   
  8.      Description:    Contains C code specific to the validation code resource
  9.                      of a simple file transfer tool.
  10.   
  11.                           Copyright © 1992 Apple Computer, Inc.
  12.                           All rights reserved.
  13.   
  14. *************************************************************************************
  15.                               A U T H O R   I D E N T I T Y
  16. *************************************************************************************
  17.   
  18.       Initials    Name
  19.       --------    -----------------------------------------------
  20.       CH            Craig Hotchkiss
  21.   
  22. *************************************************************************************
  23.                               R E V I S I O N   H I S T O R Y
  24. *************************************************************************************
  25.  
  26.     Change History (most recent first):
  27.  
  28.          <0>      5/8/92    CH        Creation date
  29.  
  30. ************************************************************************************/
  31.  
  32.  
  33.  
  34. /************************************************************************************
  35.                                 STANDARD Mac HEADERS 
  36. ************************************************************************************/
  37.  
  38. #ifdef DUMPFILENAME
  39.     #pragma load DUMPFILENAME
  40. #else
  41.     #define    DoNotDump     1
  42.     #include Load.c
  43. #endif
  44.  
  45.  
  46.  
  47. /************************************************************************************
  48.                                 Other dependent HEADERs
  49. ************************************************************************************/
  50.  
  51. #ifndef __VALIDATION__
  52.     #include "Validation.h"
  53. #endif
  54.  
  55. #ifndef __CONSTANTS__
  56.     #include "Constants.h"
  57. #endif
  58.  
  59. #ifndef __GLOBALS__
  60.     #include "Globals.h"
  61. #endif
  62.  
  63.  
  64.  
  65. /************************************************************************************
  66. ************************************************************************************/
  67.  
  68. /*****************************************************************************
  69. *    Procedure:    MakeTempResourceFile
  70. *    Purpose:    Creates temporary files
  71. *    Passed:        theReply:        a ptr to a sfreply record
  72. *                theFileSpec:    a ptr to the FSSpec record
  73. *    Returns:    An OSErr indicating nature of the failure
  74. ******************************************************************************/
  75. OSErr        MakeTempResourceFile( FSSpec* spec)
  76. {
  77.     OSErr                retValue = noErr;
  78.     short                tempVRefNum;
  79.     long                tempDirID;
  80.     unsigned long        seconds;
  81.     Str255                tempFileName;
  82.     #if Debugging == 1
  83.         #if OSErrDebug == 1
  84.             Str255            tempString;
  85.         #endif
  86.     #endif
  87.  
  88.  
  89.     GetDateTime( &seconds );
  90.     NumToString( (long) seconds, tempFileName );
  91.  
  92.     if ( noErr == ( retValue = FindFolder(    
  93.                                 kOnSystemDisk,
  94.                                 kTemporaryFolderType,
  95.                                 kCreateFolder,
  96.                                 &tempVRefNum,
  97.                                 &tempDirID ) ) ) {
  98.         if ( fnfErr == ( retValue = FSMakeFSSpec(
  99.                                     tempVRefNum,
  100.                                     tempDirID,
  101.                                     tempFileName,
  102.                                     spec ) ) ) {
  103.             FSpCreateResFile( spec, '????', 'pref', smSystemScript );
  104.             if ( noErr == ( retValue = ResError() ) ) {
  105.             } else {
  106.                 #if Debugging == 1
  107.                     #if OSErrDebug == 1
  108.                         DebugStr( "\p OSErr at MakeTempFile/FSpCreateResFile" );
  109.                         NumToString( (long) retValue, tempString );
  110.                         DebugStr( tempString );
  111.                     #endif
  112.                 #endif
  113.             }
  114.         } else {
  115.             if ( noErr != retValue ) {
  116.                 #if Debugging == 1
  117.                     #if OSErrDebug == 1
  118.                         DebugStr( "\p OSErr at MakeTempFile/FSMakeFSSpec" );
  119.                         NumToString( (long) retValue, tempString );
  120.                         DebugStr( tempString );
  121.                     #endif
  122.                 #endif
  123.             }
  124.         }
  125.     } else {
  126.         #if Debugging == 1
  127.             #if OSErrDebug == 1
  128.                 DebugStr( "\p OSErr at MakeTempFile/FindFolder" );
  129.                 NumToString( (long) retValue, tempString );
  130.                 DebugStr( tempString );
  131.             #endif
  132.         #endif
  133.     }
  134.  
  135.     return ( retValue );
  136. } /*MakeTempResourceFile*/
  137.  
  138.  
  139.  
  140. /************************************************************************************
  141.      Procedure:    PrefsExists
  142.  
  143.      Purpose:    
  144.  
  145.      Inputs:        
  146.  
  147.      Outputs:
  148. ************************************************************************************/
  149. Boolean        PrefsExists( FSSpec* spec, Str32 fileName )
  150. {
  151.     Boolean                    retValue = true;
  152.     OSErr                    osResult = noErr;
  153.     short                    fileVRefNum;
  154.     long                    fileDirID;
  155.     #if Debugging == 1
  156.         #if OSErrDebug == 1
  157.             Str255            tempString;
  158.         #endif
  159.     #endif
  160.     
  161.     
  162.     if ( noErr == ( osResult = FindFolder(    
  163.                                 kOnSystemDisk,
  164.                                 kPreferencesFolderType,
  165.                                 kCreateFolder,
  166.                                 &fileVRefNum,
  167.                                 &fileDirID ) ) ) {
  168.         if ( fnfErr == ( osResult = FSMakeFSSpec(
  169.                                     fileVRefNum,
  170.                                     fileDirID,
  171.                                     fileName,
  172.                                     spec ) ) ) {
  173.                 /* we now know the file exists */
  174.             retValue = false;
  175.         } else {
  176.             if ( noErr != osResult ) {
  177.                 #if Debugging == 1
  178.                     #if OSErrDebug == 1
  179.                         DebugStr( "\p OSErr at PrefsExists/FSMakeFSSpec" );
  180.                         NumToString( (long) osResult, tempString );
  181.                         DebugStr( tempString );
  182.                     #endif
  183.                 #endif
  184.             }
  185.         }
  186.     } else {
  187.         #if Debugging == 1
  188.             #if OSErrDebug == 1
  189.                 DebugStr( "\p OSErr at PrefsExists/FindFolder" );
  190.                 NumToString( (long) osResult, tempString );
  191.                 DebugStr( tempString );
  192.             #endif
  193.         #endif
  194.     }
  195.  
  196.     return ( retValue );
  197. } /*PrefsExists*/
  198.  
  199.  
  200.  
  201. /************************************************************************************
  202.      Procedure:    MakeTempPrefsFile
  203.  
  204.      Purpose:    
  205.  
  206.      Inputs:        
  207.  
  208.      Outputs:
  209. ************************************************************************************/
  210. OSErr        MakeTempPrefsFile( FSSpec* tempSpec, short toolRefNum )
  211. {
  212.     OSErr                    retValue = noErr;
  213.     short                    savedResFile = CurResFile(), 
  214.                             tempRefNum, 
  215.                             i;
  216.     Handle                    tempHandle;
  217.     OSType                    typeArray[] = {
  218.                                 kDefaultType, 
  219.                                 'TMPL', 
  220.                                 'TMPL', 
  221.                                 'flst'
  222.                             };
  223.     short                    idArray[] = {
  224.                                 rDefaultConfigID, 
  225.                                 rDefaultTemplateID, 
  226.                                 rFlstTemplateID, 
  227.                                 rFlstID
  228.                             };
  229.     Str255                    resNameArray[] = {
  230.                                 "\pDefault configuration data", 
  231.                                 kDefaultResName, 
  232.                                 kFlstResName, 
  233.                                 "\pWindow Font Information"
  234.                             };
  235.     #if Debugging == 1
  236.         #if OSErrDebug == 1
  237.             Str255            tempString;
  238.         #endif
  239.     #endif
  240.     
  241.  
  242.     #if Debugging == 1
  243.         #if PrefsDebug == 1
  244.             DebugStr( "\p Entering MakeTempPrefsFile.;g" );
  245.         #endif
  246.     #endif
  247.  
  248.     if ( noErr == ( retValue = MakeTempResourceFile( tempSpec ) ) ) {
  249.         #if Debugging == 1
  250.             #if PrefsDebug == 1
  251.                 DebugStr( "\p Made it through MakeTempResourceFile.;g" );
  252.             #endif
  253.         #endif
  254.     
  255.         if ( ( -1 ) != ( tempRefNum = FSpOpenResFile( tempSpec, fsCurPerm ) ) ) {
  256.             #if Debugging == 1
  257.                 #if PrefsDebug == 1
  258.                     DebugStr( "\p FSpOpenResFile on tempSpec.;g" );
  259.                 #endif
  260.             #endif
  261.             
  262.             for ( i = 0; i < ( sizeof( typeArray ) / 4 ); ++i ) {
  263.             
  264.                     /* set the current resource file to be the tool */
  265.                 UseResFile( toolRefNum );
  266.                 if ( nil != ( tempHandle = Get1Resource( typeArray[ i ], idArray[ i ] ) ) ) {
  267.                     HLock( tempHandle );
  268.                     HNoPurge( tempHandle );
  269.  
  270.                     DetachResource( tempHandle );
  271.                     if ( noErr == ( retValue = ResError() ) ) {
  272.                         UseResFile( tempRefNum );
  273.                         
  274.                         AddResource( tempHandle, typeArray[ i ], idArray[ i ], resNameArray[ i ] );
  275.                         if ( noErr == ( retValue = ResError() ) ) {
  276.                             HPurge( tempHandle );
  277.                             HUnlock( tempHandle );
  278.                             
  279.                             UpdateResFile( tempRefNum );
  280.                             if ( noErr == ( retValue = ResError() ) ) {
  281.                                 ReleaseResource( tempHandle );
  282.                                 
  283.                                 #if Debugging == 1
  284.                                     #if PrefsDebug == 1
  285.                                         DebugStr( "\p UpdateResFile on tempfile.;g" );
  286.                                     #endif
  287.                                 #endif
  288.                             } else {
  289.                                 #if Debugging == 1
  290.                                     #if OSErrDebug == 1
  291.                                         DebugStr( "\p ResError at MakeTempPrefsFile/UpdateResFile.;g" );
  292.                                         NumToString( (long) retValue, tempString );
  293.                                         DebugStr( tempString );
  294.                                     #endif
  295.                                 #endif
  296.                                 
  297.                                 break;
  298.                             }
  299.                         } else {
  300.                             #if Debugging == 1
  301.                                 #if OSErrDebug == 1
  302.                                     DebugStr( "\p ResError at MakeTempPrefsFile/AddResource.;g" );
  303.                                     NumToString( (long) retValue, tempString );
  304.                                     DebugStr( tempString );
  305.                                 #endif
  306.                             #endif
  307.                             
  308.                             break;
  309.                         }
  310.                     } else {
  311.                         #if Debugging == 1
  312.                             #if OSErrDebug == 1
  313.                                 DebugStr( "\p ResError at MakeTempPrefsFile/DetachResource.;g" );
  314.                                 NumToString( (long) retValue, tempString );
  315.                                 DebugStr( tempString );
  316.                             #endif
  317.                         #endif
  318.                         
  319.                         break;
  320.                     }
  321.                 } else {
  322.                     retValue = ResError();
  323.                     #if Debugging == 1
  324.                         #if OSErrDebug == 1
  325.                             DebugStr( "\p ResError at MakeTempPrefsFile/Get1Resource.;g" );
  326.                             NumToString( (long) retValue, tempString );
  327.                             DebugStr( tempString );
  328.                         #endif
  329.                     #endif
  330.                     
  331.                     break;
  332.                 }
  333.             } /* for each resource */
  334.             
  335.             if ( noErr == ( retValue = FSClose( tempRefNum ) ) ) {
  336.             } else {
  337.                 #if Debugging == 1
  338.                     #if OSErrDebug == 1
  339.                         DebugStr( "\p OSErr at MakeTempPrefsFile/FSClose.;g" );
  340.                         NumToString( (long) retValue, tempString );
  341.                         DebugStr( tempString );
  342.                     #endif
  343.                 #endif
  344.             }
  345.         } else {
  346.             #if Debugging == 1
  347.                 #if OSErrDebug == 1
  348.                     retValue = ResError();
  349.                     
  350.                     DebugStr( "\p ResError at MakeTempPrefsFile/FSpOpenResFile.;g" );
  351.                     NumToString( (long) retValue, tempString );
  352.                     DebugStr( tempString );
  353.                 #endif
  354.             #endif
  355.         }
  356.     } else {
  357.         #if Debugging == 1
  358.             #if OSErrDebug == 1
  359.                 DebugStr( "\p OSErr at MakeTempPrefsFile/MakeTempFile.;g" );
  360.                 NumToString( (long) retValue, tempString );
  361.                 DebugStr( tempString );
  362.             #endif
  363.         #endif
  364.     }
  365.         
  366.         /*    create tempfile
  367.             copy defaults to tempfile
  368.             create prefs
  369.             FSpExchangeFiles
  370.             delete tempfile */
  371.  
  372.         /* restore original resource file */
  373.     UseResFile( savedResFile );
  374.     
  375.     return ( retValue );
  376. } /*MakeTempPrefsFile*/
  377.  
  378.  
  379.  
  380. /************************************************************************************
  381.      Procedure:    GetPrefsSpec
  382.  
  383.      Purpose:    
  384.  
  385.      Inputs:        
  386.  
  387.      Outputs:
  388. ************************************************************************************/
  389. OSErr        GetPrefsSpec( FSSpec* spec, short toolRefNum )
  390. {
  391.     OSErr                    retValue = noErr;
  392.     FSSpec                    tempSpec;
  393.     #if Debugging == 1
  394.         #if OSErrDebug == 1
  395.             Str255            tempString;
  396.         #endif
  397.     #endif
  398.     
  399.     
  400.     if ( PrefsExists( spec, kPrefsFileName ) ) {
  401.         #if Debugging == 1
  402.             #if PrefsDebug == 1
  403.                 DebugStr( "\p Prefs file DOES exist.;g" );
  404.             #endif
  405.         #endif
  406.     } else {
  407.         #if Debugging == 1
  408.             #if PrefsDebug == 1
  409.                 DebugStr( "\p Prefs file does NOT exist.;g" );
  410.             #endif
  411.         #endif
  412.     
  413.         if ( noErr == ( retValue = MakeTempPrefsFile( &tempSpec, toolRefNum ) ) ) {
  414.             #if Debugging == 1
  415.                 #if PrefsDebug == 1
  416.                     DebugStr( "\p MakeTempPrefsFile on the tempfile.;g" );
  417.                 #endif
  418.             #endif
  419.             
  420.             FSpCreateResFile( spec, '????', 'pref', smSystemScript );
  421.             if ( noErr == ( retValue = ResError() ) ) {
  422.                 #if Debugging == 1
  423.                     #if PrefsDebug == 1
  424.                         DebugStr( "\p FSpCreateResFile on prefs.;g" );
  425.                     #endif
  426.                 #endif
  427.                 
  428.                 if ( noErr == ( retValue = FSpExchangeFiles(    &tempSpec, 
  429.                                                                 spec ) ) ) {
  430.     
  431.                     #if Debugging == 1
  432.                         #if PrefsDebug == 1
  433.                             DebugStr( "\p FSpExchangeFiles on prefs.;g" );
  434.                         #endif
  435.                     #endif
  436.                     
  437.                     if ( noErr == ( retValue = FSpDelete( &tempSpec ) ) ) {
  438.                         #if Debugging == 1
  439.                             #if PrefsDebug == 1
  440.                                 DebugStr( "\p FSpDelete on the tempfile.;g" );
  441.                             #endif
  442.                         #endif
  443.                     } else {
  444.                         #if Debugging == 1
  445.                             #if OSErrDebug == 1
  446.                                 DebugStr( "\p OSErr at GetPrefsSpec/DeleteTempFile.;g" );
  447.                                 NumToString( (long) retValue, tempString );
  448.                                 DebugStr( tempString );
  449.                             #endif
  450.                         #endif
  451.                     }
  452.                 } else {
  453.                     #if Debugging == 1
  454.                         #if OSErrDebug == 1
  455.                             DebugStr( "\p OSErr at GetPrefsSpec/FSpExchangeFiles.;g" );
  456.                             NumToString( (long) retValue, tempString );
  457.                             DebugStr( tempString );
  458.                         #endif
  459.                     #endif
  460.                 }
  461.             } else {
  462.                 #if Debugging == 1
  463.                     #if OSErrDebug == 1
  464.                         DebugStr( "\p OSErr at GetPrefsSpec/FSpCreateResFile.;g" );
  465.                         NumToString( (long) retValue, tempString );
  466.                         DebugStr( tempString );
  467.                     #endif
  468.                 #endif
  469.             }
  470.         } else {
  471.             #if Debugging == 1
  472.                 #if OSErrDebug == 1
  473.                     DebugStr( "\p OSErr at GetPrefsSpec/MakeTempPrefsFile.;g" );
  474.                     NumToString( (long) retValue, tempString );
  475.                     DebugStr( tempString );
  476.                 #endif
  477.             #endif
  478.         }
  479.     }
  480.     
  481.     return ( retValue );
  482. } /*GetPrefsSpec*/
  483.  
  484.  
  485.  
  486. /************************************************************************************
  487.      Procedure:    FillFromDefaults
  488.  
  489.      Purpose:    
  490.  
  491.      Inputs:        
  492.  
  493.      Outputs:
  494. ************************************************************************************/
  495. OSErr        FillFromDefaults( ConfigGlobalRec* pConfig, short toolRefNum )
  496. {
  497.     OSErr                    retValue = noErr;
  498.     short                    savedResFile = CurResFile(), 
  499.                             toolResFile = toolRefNum, 
  500.                             tempRefNum;
  501.     Handle                    tempHandle;
  502.     FSSpec                    prefsSpec;
  503.     #if Debugging == 1
  504.         #if OSErrDebug == 1
  505.             Str255            tempString;
  506.         #endif
  507.     #endif
  508.     
  509.     
  510.     if ( noErr == ( retValue = GetPrefsSpec( &prefsSpec, toolRefNum ) ) ) {
  511.         if ( ( -1 ) != ( tempRefNum = FSpOpenResFile( &prefsSpec, fsCurPerm ) ) ) {
  512.             #if Debugging == 1
  513.                 #if PrefsDebug == 1
  514.                     DebugStr( "\p FSpOpenResFile on prefs.;g" );
  515.                 #endif
  516.             #endif
  517.             
  518.             if ( nil != ( tempHandle = Get1Resource( kDefaultType, rDefaultConfigID ) ) ) {
  519.                 #if Debugging == 1
  520.                     #if PrefsDebug == 1
  521.                         DebugStr( "\p tempHandle from prefs is valid:;g" );
  522.                     #endif
  523.                 #endif
  524.                 
  525.                 DetachResource( tempHandle );
  526.                 if ( noErr == ( retValue = ResError() ) ) {
  527.                     if ( sizeof( ConfigGlobalRec ) == GetHandleSize( tempHandle ) ) {
  528.                             /* Move the resource to our config pointer */
  529.                         BlockMove( (*tempHandle), pConfig, sizeof( ConfigGlobalRec ) );
  530.                         
  531.                         #if Debugging == 1
  532.                             #if PrefsDebug == 1
  533.                                 DebugStr( "\p We've BlockMove'ed the config.;g" );
  534.                             #endif
  535.                         #endif
  536.                         
  537.                         #if Debugging == 1
  538.                             #if ShowDefaults == 1
  539.                                 DebugStr( "\p pConfig->fToolVersion is:;g" );
  540.                                 NumToString( (long) pConfig->fToolVersion, tempString );
  541.                                 DebugStr( tempString );
  542.  
  543.                                 DebugStr( "\p pConfig->fPersistentPackets is:;g" );
  544.                                 NumToString( (long) pConfig->fPersistentPackets, tempString );
  545.                                 DebugStr( tempString );
  546.  
  547.                                 DebugStr( "\p pConfig->fOKToContinue is:;g" );
  548.                                 NumToString( (long) pConfig->fOKToContinue, tempString );
  549.                                 DebugStr( tempString );
  550.                             #endif
  551.                         #endif
  552.                     } else {
  553.                         #if Debugging == 1
  554.                             #if OSErrDebug == 1
  555.                                 DebugStr( "\p Incorrect handle size FillFromDefaults/ConfigGlobalRec." );
  556.                             #endif
  557.                         #endif
  558.                     }
  559.                 } else {
  560.                     #if Debugging == 1
  561.                         #if OSErrDebug == 1
  562.                             DebugStr( "\p ResError at FillFromDefaults/DetachResource.;g" );
  563.                             NumToString( (long) retValue, tempString );
  564.                             DebugStr( tempString );
  565.                         #endif
  566.                     #endif
  567.                 }
  568.             } else {
  569.                 retValue = ResError();
  570.                 #if Debugging == 1
  571.                     #if OSErrDebug == 1
  572.                         DebugStr( "\p ResError at FillFromDefaults/Get1Resource.;g" );
  573.                         NumToString( (long) retValue, tempString );
  574.                         DebugStr( tempString );
  575.                     #endif
  576.                 #endif
  577.             }
  578.                 
  579.             if ( noErr == ( retValue = FSClose( tempRefNum ) ) ) {
  580.             } else {
  581.                 #if Debugging == 1
  582.                     #if OSErrDebug == 1
  583.                         DebugStr( "\p OSErr at FillFromDefaults/FSClose.;g" );
  584.                         NumToString( (long) retValue, tempString );
  585.                         DebugStr( tempString );
  586.                     #endif
  587.                 #endif
  588.             }
  589.         } else {
  590.             #if Debugging == 1
  591.                 #if OSErrDebug == 1
  592.                     retValue = ResError();
  593.                     
  594.                     DebugStr( "\p ResError at FillFromDefaults/FSpOpenResFile.;g" );
  595.                     NumToString( (long) retValue, tempString );
  596.                     DebugStr( tempString );
  597.                 #endif
  598.             #endif
  599.         }
  600.     } else {
  601.         #if Debugging == 1
  602.             #if OSErrDebug == 1
  603.                 DebugStr( "\p OSErr at FillFromDefaults/GetPrefsSpec.;g" );
  604.                 NumToString( (long) retValue, tempString );
  605.                 DebugStr( tempString );
  606.             #endif
  607.         #endif
  608.     }
  609.     
  610.     return ( retValue );
  611. } /*FillFromDefaults*/
  612.  
  613.  
  614.  
  615. /************************************************************************************
  616.      Procedure:    RangeCheckConfig
  617.  
  618.      Purpose:    
  619.  
  620.      Inputs:        
  621.  
  622.      Outputs:
  623. ************************************************************************************/
  624. OSErr        RangeCheckConfig( ConfigGlobalRec* pConfig, short toolRefNum )
  625. {
  626.     OSErr                retValue = noErr;
  627.     short                savedResFile = CurResFile(), 
  628.                         toolResFile = toolRefNum;
  629.     
  630.     
  631.         /* check out our version number */
  632.     if ( kThisToolVersion != ( pConfig->fToolVersion ) ) {
  633.         pConfig->fToolVersion = kThisToolVersion;
  634.     }
  635.  
  636.     if ( ( 0 != ( pConfig->fPersistentPackets ) ) ||
  637.             ( 1 != ( pConfig->fPersistentPackets ) ) ) {
  638.         pConfig->fPersistentPackets = true;
  639.     }
  640.     
  641.     if ( ( 0 != ( pConfig->fOKToContinue ) ) ||
  642.             ( 1 != ( pConfig->fOKToContinue ) ) ) {
  643.         pConfig->fOKToContinue = true;
  644.     }
  645.     
  646.     return ( retValue );
  647. } /*RangeCheckConfig*/
  648.  
  649.  
  650.  
  651. /************************************************************************************
  652.      Procedure:    VerifyConfig
  653.  
  654.      Purpose:    
  655.  
  656.      Inputs:        
  657.  
  658.      Outputs:
  659. ************************************************************************************/
  660. OSErr        VerifyConfig( ConfigGlobalRec* pConfig, Boolean pullDefaults, short toolRefNum )
  661. {
  662.     OSErr                retValue = noErr;
  663.     
  664.     
  665.     if ( sizeof( ConfigGlobalRec ) == GetPtrSize( (Ptr) pConfig ) ) {
  666.         if ( pullDefaults ) {
  667.             if ( noErr == ( retValue = FillFromDefaults( pConfig, toolRefNum ) ) ) {
  668.             } else {
  669.             }
  670.         } else {
  671.                 /* ftGenericError tells us something's wrong */
  672.             if ( ftGenericError == ( retValue = RangeCheckConfig( pConfig, toolRefNum ) ) ) {
  673.             } else {
  674.             }
  675.         }
  676.         
  677.     } else {
  678.         retValue = ftGenericError;
  679.     }
  680.     
  681.     return ( retValue );
  682. } /*VerifyConfig*/
  683.  
  684.  
  685.  
  686. /************************************************************************************
  687.      Procedure:    DoToolDefault
  688.  
  689.      Purpose:    
  690.  
  691.      Inputs:        
  692.  
  693.      Outputs:
  694. ************************************************************************************/
  695. OSErr        DoToolDefault( Ptr* configPtr, Boolean allocateIt, short toolRefNum )
  696. {
  697.     OSErr                retValue = noErr;
  698.     
  699.     
  700.     if ( allocateIt ) {
  701.         if ( nil != ( *configPtr = NewPtrClear( sizeof( ConfigGlobalRec ) ) ) ) {
  702.         } else {
  703.             retValue = MemError();
  704.         }
  705.     }
  706.     
  707.     if ( ( noErr == retValue ) && 
  708.             ( noErr == ( retValue = VerifyConfig(    (ConfigGlobalRec*) *configPtr, 
  709.                                                     true, 
  710.                                                     toolRefNum ) ) ) ) {
  711.     } else {
  712.         retValue = ftGenericError;
  713.     }
  714.     
  715.     return ( retValue );
  716. } /*DoToolDefault*/
  717.  
  718.  
  719.  
  720. /************************************************************************************
  721.      Procedure:    DoToolValidate
  722.  
  723.      Purpose:    
  724.  
  725.      Inputs:        
  726.  
  727.      Outputs:
  728. ************************************************************************************/
  729. OSErr        DoToolValidate( FTHandle toolHandle )
  730. {
  731.     OSErr                retValue = noErr;
  732.     ToolGlobalRec*        pGlobals;
  733.     ConfigGlobalRec*    pConfig;
  734.     
  735.     
  736.     if ( ( nil != toolHandle ) && 
  737.             ( nil != ( pConfig = (ConfigGlobalRec*) ( (**toolHandle).config ) ) ) && 
  738.             ( nil != ( pGlobals = (ToolGlobalRec*) ( (**toolHandle).ftPrivate ) ) ) ) {
  739.         
  740.         if ( noErr == ( retValue = VerifyConfig( pConfig, false, (**toolHandle).procID ) ) ) {
  741.         }
  742.     } else {
  743.         retValue = ftGenericError;
  744.     }
  745.     
  746.     return ( retValue );
  747. } /*DoToolValidate*/
  748.